package config

import "yu.DbPrime/src/db"

var (
	/*
		Book表
	*/
	book_id = db.Item{
		FieldType: "int",
		FieldName: "id",
	}
	book_title = db.Item{
		FieldType: "string",
		FieldName: "title",
	}
	book_authors = db.Item{
		FieldName: "authors",
		FieldType: "string",
	}
	book_publisher_id = db.Item{
		FieldName: "publisher_id",
		FieldType: "int",
	}
	book_copies = db.Item{
		FieldName: "copies",
		FieldType: "int",
	}

	v1 = db.Vertical_strategy{
		Site:          "Site1",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{book_id, book_title}),
	}
	v2 = db.Vertical_strategy{
		Site:          "Site2",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{book_id, book_authors, book_publisher_id, book_copies}),
	}
	Book_table = db.TableInfo{
		Name:          "book",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{book_id, book_title, book_authors, book_publisher_id, book_copies}),
		Strategy_type: 0,
		Vertical:      []db.Vertical_strategy{v1, v2},
	}
)

// Customer表
var (
	customer_id = db.Item{
		FieldName: "id",
		FieldType: "int",
	}
	customer_name = db.Item{
		FieldName: "name",
		FieldType: "string",
	}
	customer_gender = db.Item{
		FieldName: "gender",
		FieldType: "string",
	}
	l1 = db.Level_strategy{
		Site: "Site1",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  customer_id,
				Symbol:    db.LessThanStr,
				Parameter: "305000"},
		},
	}
	l2 = db.Level_strategy{
		Site: "Site2",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  customer_id,
				Symbol:    db.GreaterEqualStr,
				Parameter: "305000",
			},
			db.L_strategy{
				ItemInfo:  customer_id,
				Symbol:    db.LessThanStr,
				Parameter: "310000"},
		},
	}
	l3 = db.Level_strategy{
		Site: "Site3",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  customer_id,
				Symbol:    db.GreaterEqualStr,
				Parameter: "310000"},
		},
	}
	Customer_table = db.TableInfo{
		Name:          "customer",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{customer_id, book_title, customer_name, customer_gender}),
		Strategy_type: 1,
		Level:         []db.Level_strategy{l1, l2, l3},
	}
)

// Orders表
var (
	order_customer_id = db.Item{
		FieldName: "customer_id",
		FieldType: "int",
	}
	order_book_id = db.Item{
		FieldName: "book_id",
		FieldType: "int",
	}
	order_quantity = db.Item{
		FieldName: "quantity",
		FieldType: "string",
	}
	lo1 = db.Level_strategy{
		Site: "Site1",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  order_customer_id,
				Symbol:    db.LessEqualStr,
				Parameter: "307500"},
			db.L_strategy{
				ItemInfo:  order_book_id,
				Symbol:    db.LessEqualStr,
				Parameter: "245000"},
		},
	}
	lo2 = db.Level_strategy{
		Site: "Site2",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  order_customer_id,
				Symbol:    db.LessEqualStr,
				Parameter: "307500",
			},
			db.L_strategy{
				ItemInfo:  order_book_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "245000"},
		},
	}
	lo3 = db.Level_strategy{
		Site: "Site3",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  order_customer_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "307500",
			},
			db.L_strategy{
				ItemInfo:  order_book_id,
				Symbol:    db.LessEqualStr,
				Parameter: "245000"},
		},
	}
	lo4 = db.Level_strategy{
		Site: "Site4",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  order_customer_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "307500",
			},
			db.L_strategy{
				ItemInfo:  order_book_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "245000"},
		},
	}
	Orders_table = db.TableInfo{
		Name:          "orders",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{order_customer_id, order_book_id, order_quantity}),
		Strategy_type: 1,
		Level:         []db.Level_strategy{lo1, lo2, lo3, lo4},
	}
)

// Publisher表
var (
	publisher_id = db.Item{
		FieldName: "id",
		FieldType: "int",
	}
	publisher_name = db.Item{
		FieldName: "name",
		FieldType: "string",
	}
	publisher_state = db.Item{
		FieldName: "state",
		FieldType: "string",
	}
	lp1 = db.Level_strategy{
		Site: "Site1",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  publisher_id,
				Symbol:    db.LessEqualStr,
				Parameter: "102500"},
			db.L_strategy{
				ItemInfo:  publisher_state,
				Symbol:    db.EqualStr,
				Parameter: "CA"},
		},
	}
	lp2 = db.Level_strategy{
		Site: "Site2",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  publisher_id,
				Symbol:    db.LessEqualStr,
				Parameter: "102500"},
			db.L_strategy{
				ItemInfo:  publisher_state,
				Symbol:    db.EqualStr,
				Parameter: "GA"},
		},
	}
	lp3 = db.Level_strategy{
		Site: "Site3",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  publisher_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "102500"},
			db.L_strategy{
				ItemInfo:  publisher_state,
				Symbol:    db.EqualStr,
				Parameter: "CA"},
		},
	}
	lp4 = db.Level_strategy{
		Site: "Site4",
		Strategy: []db.L_strategy{
			db.L_strategy{
				ItemInfo:  publisher_id,
				Symbol:    db.GreaterThanStr,
				Parameter: "102500"},
			db.L_strategy{
				ItemInfo:  publisher_state,
				Symbol:    db.EqualStr,
				Parameter: "GA"},
		},
	}
	Publisher_table = db.TableInfo{
		Name:          "publisher",
		TupleDescInfo: *db.NewTupleDesc([]db.Item{publisher_id, publisher_name, publisher_state}),
		Strategy_type: 1,
		Level:         []db.Level_strategy{lp1, lp2, lp3, lp4},
	}
)
